a[351][351];main(n,i,j,t,y){scanf("%d",&n);for(j=0;j<n;j++)for(i=0;i<=j;scanf("%d",&a[i++][j]));for(j=n;j-->0;)for(i=0;i<j;y=a[i+1][j],a[i++][j-1]+=t>y?t:y)t=a[i][j];printf("%d",**a);}
